package com.jiangzehui.www.polygonsview.slice;

import com.jiangzehui.www.Polygonsview;

import com.jiangzehui.www.polygonsview.ResourceTable;
import ohos.aafwk.ability.AbilitySlice;
import ohos.aafwk.content.Intent;
import ohos.agp.components.Slider;

public class MainAbilitySlice extends AbilitySlice implements Slider.ValueChangedListener{
    Polygonsview mv;
    Slider sb1, sb2, sb3, sb4, sb5, sb6, sb7;
    @Override
    public void onStart(Intent intent) {
        super.onStart(intent);
        super.setUIContent(ResourceTable.Layout_ability_main);
        mv = (Polygonsview) findComponentById(ResourceTable.Id_mv);
        sb1 = (Slider) findComponentById(ResourceTable.Id_sb1);
        sb1.setValueChangedListener(this);

        sb2 = (Slider) findComponentById(ResourceTable.Id_sb2);
        sb2.setValueChangedListener(this);

        sb3 = (Slider) findComponentById(ResourceTable.Id_sb3);

        sb3.setValueChangedListener(this);
        sb4 = (Slider) findComponentById(ResourceTable.Id_sb4);

        sb4.setValueChangedListener(this);
        sb5 = (Slider) findComponentById(ResourceTable.Id_sb5);

        sb5.setValueChangedListener(this);
        sb6 = (Slider) findComponentById(ResourceTable.Id_sb6);

        sb6.setValueChangedListener(this);
        sb7 = (Slider) findComponentById(ResourceTable.Id_sb7);

        sb7.setValueChangedListener(this);
    }

    @Override
    public void onActive() {
        super.onActive();
    }

    @Override
    public void onForeground(Intent intent) {
        super.onForeground(intent);
    }

    @Override
    public void onProgressUpdated(Slider slider, int i, boolean b) {
        float values = (float) (slider.getProgress() / 10.0);
        switch (slider.getId()) {
            case ResourceTable.Id_sb1:
                mv.setValue1(values);
                break;
            case ResourceTable.Id_sb2:
                mv.setValue2(values);
                break;
            case ResourceTable.Id_sb3:
                mv.setValue3(values);
                break;
            case ResourceTable.Id_sb4:
                mv.setValue4(values);
                break;
            case ResourceTable.Id_sb5:
                mv.setValue5(values);
                break;
            case ResourceTable.Id_sb6:
                mv.setValue6(values);
                break;
            case ResourceTable.Id_sb7:
                mv.setValue7(values);
                break;
        }
    }

    @Override
    public void onTouchStart(Slider slider) {

    }

    @Override
    public void onTouchEnd(Slider slider) {

    }
}
